package com.dinian.zeus.util;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * @Author dinian
 * @Date 2018-12-26
 */
@Getter
@Setter
@ToString
public class Result {

    private static final String SUCCESS_CODE = "200";
    private static final String FAIL_CODE = "500";
    private static final String SUCCESS_MSG = "success";
    private static final String FAIL_MSG = "failure";

    private String code;
    private String msg;
    private Object data;

    private Result(String code, String msg){
        this.code = code;
        this.msg = msg;
    }

    private Result(String code, String msg,Object object){
        this.code = code;
        this.msg = msg;
        this.data = object;
    }

    public static Result ok(){
        return new Result(SUCCESS_CODE,SUCCESS_MSG);
    }

    public static Result ok(Object object){
        return new Result(SUCCESS_CODE,SUCCESS_MSG,object);
    }

    public static Result error(){
        return new Result(FAIL_CODE,FAIL_MSG);
    }

    public static Result error(Object object){
        return new Result(FAIL_CODE,FAIL_MSG,object);
    }
}
